<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport"
  content="width=device-width, initial-scale=1.0, minimum-scale=1,maximum-scale=1,user-scalable=no">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title data-ch="恐龙探险" data-en="Dinosaur Adventure" class="document_title">恐龙探险</title>
 <script src="js/jquery-3.3.1.min.js"></script>
 <script src="js/common.js"></script>
 <script src="js/rem.js"></script>
 <script src="js/layer.js"></script>
 <script type="text/javascript">
  isLogin();
 </script>
 <link rel="stylesheet" href="css/common.css">
 <link rel="stylesheet" type="text/css" href="css/css.css">
</head>
<body>
<!--头部-->
<div class="jui_top_bar">
    <a class="jui_top_left" href="javascript:history.back(-1)"><img src="icons/back.png"></a>
    <div class="jui_top_middle" data-ch="更改交易密码" data-en="Change secondary password">更改交易密码</div>
</div>
<!--头部end--> 
<!--主体-->
<form action="">
<div class="jui_main">
  <div class="jui_pad_12">
   <div class="bg_light_black jui_bor_rad_15 jui_pad_20">
    <div class="col_fff jui_pad_b5" data-ch="当前交易密码" data-en="Current secondary password">当前交易密码</div>
    <input id="jiaoyi_old" class="jui_bor_rad_5 smrz_input" data-ch="请输入当前交易密码" data-en="Please key in current secondary password" type="password" value=""
     placeholder="请输入当前交易密码">
    <div class="jui_h16"></div>
    <div class="col_fff jui_pad_b5" data-ch="新交易密码" data-en="New secondary password">新交易密码</div>
    <input id="jiaoyi_new" class="jui_bor_rad_5 smrz_input" data-ch="请输入新交易密码" data-en="Please key in new secondary password" type="password" value="" placeholder="请输入新交易密码">
    <div class="jui_h16"></div>
    <div class="col_fff jui_pad_b5" data-ch="确认新交易密码" data-en="Confirm new secondary password">确认新交易密码</div>
    <input id="jiaoyi_sure" class="jui_bor_rad_5 smrz_input" data-ch="请确认新交易密码" data-en="Please confirm new secondary password" type="password" value="" placeholder="请确认新交易密码">
    <div class="jui_h20"></div>
    <div class="ziliao_btn" data-en="Confirm">确认</div>
   </div>
  </div>
</div>
</form>
<!--主体end-->
</body>
<script>
 $(document).ready(function(){
  var language_type = localStorage.getItem("language_type");
  $(".ziliao_btn").click(function(){
   console.log($("#jiaoyi_old").val())
   if(!$("#jiaoyi_old").val()){
    box_timer(language_type == 1 ? '请输入旧密码' : 'Please enter the old password');
   } else if(!$("#jiaoyi_new").val()){
    box_timer(language_type == 1 ? '请输入新密码' : 'Please enter the new password');
   } else if($("#jiaoyi_new").val() != $("#jiaoyi_sure").val()){
    box_timer(language_type == 1 ? '两次密码输入不一致' : 'Password did not match, Please try again');
   } else {
    var data = {
     uid: localStorage.getItem("u_id"),
     token: localStorage.getItem("token"),
     language_type: language_type,
     old_pwd: $("#jiaoyi_old").val(),
     m_pwd1: $("#jiaoyi_new").val(),
     m_pwd2: $("#jiaoyi_sure").val(),
     p_type: 2
    }
    $.ajax({
     type: 'post',
     url: baseURL + '/index.php?m=user&c=edit_pwd',
     data: data,
     success: function success(data){
      data = JSON.parse(data);
	  is_login(data);
      box_timer(data.msg);
      if(data.code == 1){
       setTimeout(function(){
        window.history.go(-1) // 返回上一页
       },1500)
      }
     }
    })
   }
  })

  language();
  documentName()
 });
</script>
</html>